<include file="Public:html:inHeader" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="__JS__/validfrom/css/style.css" type="text/css" media="all" />
<link href="__JS__/validfrom/css/demo.css" type="text/css" rel="stylesheet" />

<link href="__JS__/validfrom/plugin/jqtransform/jqtransform.css" type="text/css" rel="stylesheet" />


<script type="text/javascript" src="__JS__/validfrom/js/Validform_v5.2_min.js"></script>

<script type="text/javascript" src="__JS__/validfrom/plugin/jqtransform/jquery.jqtransform-min.js"></script>
<link href="__CSS__/table.css" rel="stylesheet" type="text/css" />
<script src="__JS__/popup/popup.js"></script>
<script src="__JS__/popup/user.js"></script>
<title>{$title|default=''}</title>
<script>
	$(document).ready(function(){
		$(".registerform").Validform({
			tiptype:function(msg,o,cssctl){
				if(!o.obj.is("form")){
					var objtip=o.obj.parents("td").next().find(".Validform_checktip");
					cssctl(objtip,o.type);
					objtip.text(msg);
				}

			},
			datatype:{
				"myemail":function(gets,obj,curform,regxp){
					/*参数gets是获取到的表单元素值，
					  obj为当前表单元素，
					  curform为当前验证的表单，
					  regxp为内置的一些正则表达式的引用。*/
					
					var reg1=regxp["m"],reg2=regxp["e"],mobile=curform.find(".mobile");
					var __mail=curform.find(".email");
					if(reg1.test(mobile.val())){__mail.attr('ignore','ignore');return true;}
					if(reg2.test(gets)){return true;}
					
					return false;
				}	
			},
			usePlugin:{
				//jqtransform:{}
			},
			ajaxPost:true,
			postonce:true,
			callback:function(data){
				alert(data.info);
				if(data.error=='n'){
					parent.window.location.href="?g=Home&m=Order&a=srvlist";
				}
				//parent.window.location.reload();
				
			}
		});
		//得到地区
		$("#AR_L1").bind('change',function(){
			if($(this).val()==''){
				return false;
			}
			$("#AR_L2").empty();
			$("#AR_L2").append('<option value="">--市辖区--</option>');
			getArea('AR_L1',$(this).val(),'AR_L2');
		});
		$("#AR_L2").bind('change',function(){
			if($(this).val()==''){
				return false;
			}
			$('#AR_L3').empty();
			$('#AR_L3').append('<option value="">--区县--</option>');
			getArea('AR_L1|AR_L2',$("#AR_L1").val()+"|"+$(this).val(),'AR_L3');
		});
		$("#AR_L3").bind('change',function(){
			if($(this).val()==''){
				return false;
			}
			$('#AR_L4').empty();
			$('#AR_L4').append('<option value="">--乡镇--</option>');
			getAreaExtend($("#AR_L1").val()+"|"+$("#AR_L2").val()+"|"+$(this).val());
		});
	});
	
	function getArea(stName,st,fl){
		$.ajax({
			   type: "POST",
			   url: "?g=Home&m=Index&a=getArea",
			   data: "stName="+stName+"&st="+st+"&fl="+fl+'&rd'+Math.random(),
			   dataType:'json',
			   success: function(msg){
				 if(msg.sucess=='y'){
					var f=msg.fl;
					var data=msg.data;
					var _html=[];
					var k;
					for (k in data){
						_html.push('<option value="'+data[k]+'">'+data[k]+'</option>');
					}
					
					$("#"+f).append(_html.join(''));
					
					for (k in data){
						_html.push('<li><a href="javascript:;">'+data[k]+'</a></li>');
					}
					$("#"+f+"_1").append(_html.join(''));
				 }
			     
			   }
		});
	}
	function setArea(stName,st,fl,v){
		$.ajax({
			   type: "POST",
			   url: "?g=Home&m=Index&a=getArea",
			   data: "stName="+stName+"&st="+st+"&fl="+fl+'&rd'+Math.random(),
			   dataType:'json',
			   success: function(msg){
				 if(msg.sucess=='y'){
					var f=msg.fl;
					var data=msg.data;
					var _html=[];
					var k;
					for (k in data){
						var _sel='';
						if(v==data[k]){
							_sel="selected";
						}
						_html.push('<option value="'+data[k]+'"  '+_sel+'>'+data[k]+'</option>');
					}
					
					$("#"+f).append(_html.join(''));
				 }
			     
			   }
		});
	}
	
	function setAreaExtend(st,field){
		var url="st="+encodeURI(st)+'&rd='+Math.random()+"&isviewEmpty=y";
		$.ajax({
			   type: "POST",
			   url: "?g=Home&m=Index&a=getAreaExtend",
			   data: url,
			   dataType:'json',
			   success: function(msg){
				 if(msg.sucess=='y'){
					var data=msg.data;
					var _html=[];
					var k;
					for (k in data){
						var _sel='';
						if(field==data[k]){
							_sel="selected";
						}
						_html.push('<option value="'+data[k]+'" '+_sel+'>'+data[k]+'</option>');
					}
					$("#AR_L4").append(_html.join(''));
				 }
			   }
		});
	}
	function getAreaExtend(st){
		var url="st="+encodeURI(st)+'&rd='+Math.random();
		$.ajax({
			   type: "POST",
			   url: "?g=Home&m=Index&a=getAreaExtend",
			   data: url,
			   dataType:'json',
			   success: function(msg){
				 if(msg.sucess=='y'){
					var data=msg.data;
					var _html=[];
					var k;
					for (k in data){
						_html.push('<option value="'+data[k]+'">'+data[k]+'</option>');
					}
					$("#AR_L4").append(_html.join(''));
				 }
			   }
		});
	}

</script>
<style>
body{background-color:#ffffff}
</style>
</head>
<body >

<div >

	<form action="?g=Home&m=Order&a=saveOrderBack" method="post" class="registerform" id="roleForm">
		
		<fieldset>
    		<legend >地址信息</legend>
    		<table width="100%">
                 <tr>
		                  <td class="need" style="width:0px;"></td>
		                  <td style="width:80px;line-height:30px;"><span class="inputYes">*</span>地址</td>
		                  <td style="width:;">
		                  <table border="0" cellpacing="0" cellpadding="0">
							<tr>
								<td width="25%">
									<select size=1 id="AR_L1" name="data[AR_L1]" datatype="*" style="width:120px;height:20px;">
										<option value="">--省市--</option>
										<volist name="AR_L1" id="vo">
										<option value="{$vo}" <if condition="$seData.AR_L1 eq $vo">selected</if>>{$vo}</option>
										</volist>
									</select>
								</td>
							
								<td width="25%">
									<select size=1  datatype="*"  id="AR_L2" name="data[AR_L2]" style="width:120px;height:20px;">
										<option value="">--市辖区--</option>
									</select>
								</td>
								<td width="25%" >
									<select size=1 datatype="*" id="AR_L3" name="data[AR_L3]" style="width:120px;height:20px;">
										<option value="">--区县--</option>
									</select>
								</td>
								<td width="25%" >
                                <select class="select2"  id="AR_L4" name="data[AR_L4]" style="width:80px;height:20px;">
									<option value="">--乡镇--</option>
								</select>
                            	</td>
								</tr>
								
						</table>
		                  </td>
		                  <td><div class="Validform_checktip" id="Validform_checktip_AR_L" style="line-height:30px;">请输入地址</div></td>
		              </tr>
		               <tr>
		                  <td class="need" style="width:0px;"></td>
		                  <td style="width:80px;line-height:30px;">详细地址</td>
		                  <td style="width:;">
		                   <input type=text id="O_ADDRESS" name="data[O_ADDRESS]" value="{$seData.O_ADDRESS|default=''}" class="inputxt"  style="width:230px;">
		                  </td>
		                  <td><div class="Validform_checktip" id="Validform_checktip_O_ADDRESS" style="line-height:30px;">请输入详细地址</div></td>
		              </tr>
		              <tr>
		              	<td colspan="4">
		              	<div style="color:red;font-size:13px;">{$wtitle}</div>
		              	</td>
		              </tr>
		              
            </table>
		</fieldset>
    	<fieldset class="action">
    	<input type="hidden" name="o_id" value="{$o_id}">
    	<input type="hidden" name="cu_id" value="{$cu_id}">
    	<input type="submit" name="submit" id="submit" value="确认退回"  />
    	</fieldset>
    	
	</form>
</div>
<if condition="$seData.AR_L1 neq ''">
	
	<script>
		$("#AR_L2").empty();
		$("#AR_L2").append('<option value="">--市辖区--</option>');
		setArea('AR_L1',$("#AR_L1").val(),'AR_L2','{$seData.AR_L2}');
		
		$('#AR_L3').empty();
		$('#AR_L3').append('<option value="">--区县--</option>');
		setArea('AR_L1|AR_L2',"{$seData.AR_L1}|{$seData.AR_L2}",'AR_L3','{$seData.AR_L3}');
		$('#AR_L4').empty();
		$('#AR_L4').append('<option value="">--乡镇--</option>');
		setAreaExtend("{$seData.AR_L1}|{$seData.AR_L2}|{$seData.AR_L3}","{$seData.VT_NAME}");
	</script>
	
</if>

</body>
